pythonrequest能不能自动解码gzip
python request能不能自动解码gzip -
import urllib.request import gzip def getUrlContent(url):返回页面内容doc = urllib.request.urlopen(url).read()解码try:html=gzip.decompress(doc).decode("utf-8")except:html=doc.decode("utf-8")return html
import urllib.request import gzip def getUrlContent(url):返回页面内容doc = urllib.request.urlopen(url).read()解码try:html=gzip.decompress(doc).decode("utf-8")except:html=doc.decode("utf-8")return html